package com.ror.java.se.oop;

public class OverrideDemo {
    public static void main(String[] args) {
        GrandSon gs = new GrandSon();
        Son s = gs;
        Base b = gs;
        gs.sameMtd(); // GrandSon's override mtd.
        s.sameMtd(); // GrandSon's override mtd.
        b.sameMtd(); // GrandSon's override mtd.
    }

    static class Base {
        public void sameMtd() {
            System.out.println("Base's original mtd.");
        }
    }

    static class Son extends Base {
        @Override
        public void sameMtd() {
            System.out.println("Son's override mtd.");
//            System.out.println("Son's new mtd.");
        }
    }

    static class GrandSon extends Son {
        public void sameMtd() {
            System.out.println("GrandSon's override mtd.");
//            System.out.println("GrandSon's new mtd.");
        }
    }

}
